namespace GemBox.Spreadsheet
{
    using System;

    internal class NumFormulaToken : FormulaToken
    {
        private double value;

        public NumFormulaToken() : base(FormulaTokenCode.Num, 9, FormulaTokenType.Operand)
        {
        }

        public override byte[] ConvertToBytes()
        {
            byte[] array = base.ConvertToBytes();
            BitConverter.GetBytes(this.value).CopyTo(array, 1);
            return array;
        }

        public override void DelayInitialize(object[] data)
        {
            this.value = (double) data[0];
        }

        public override void Read(byte[] rpnBytes, int startIndex)
        {
            this.value = BitConverter.ToDouble(rpnBytes, startIndex);
        }

        public override string ToString()
        {
            return this.value.ToString();
        }

        public double Value
        {
            get
            {
                return this.value;
            }
        }
    }
}
